package zhxt.helmet.service;

import zhxt.helmet.dao.UserDao;
import zhxt.helmet.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.*;

import java.util.List;

@Service("userService")
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public class UserService {
    @Autowired
    private UserDao userDao;

    public User login(User user) {
        return userDao.selectByIdAndPassword(user);
    }

    public List<User> allUsers(){
        return userDao.selectAllUsers();
    }

    //添加用户
    public void addUser(User user){
        userDao.add(user);
    }
    //修改用户
    public void updateUser(User user){
        userDao.update(user);
    }
    //删除用户
    public void deleteUser(User user){
        userDao.delete(user);
    }
}
